//package com.piepesken.weight.di
//
//import android.content.Context
//import androidx.datastore.core.DataStore
//import androidx.datastore.core.handlers.ReplaceFileCorruptionHandler
//import dagger.Module
//import dagger.Provides
//import dagger.hilt.InstallIn
//import dagger.hilt.android.qualifiers.ApplicationContext
//import dagger.hilt.components.SingletonComponent
//import java.util.prefs.Preferences
//import javax.inject.Singleton
//
//private const val USER_PREFERENCES = "user_preferences"
//
//@InstallIn(SingletonComponent::class)
//@Module
//object DataStoreModule {
//    @Singleton
//    @Provides
//    fun providePreferencesDataStore(@ApplicationContext appContext: Context): DataStore<Preferences> {
//        return PreferenceDataStoreFa.create(
//            corruptionHandler = ReplaceFileCorruptionHandler(
//                produceNewData = { emptyPreferences() }
//            ),
//            migrations = listOf(SharedPreferencesMigration(appContext,USER_PREFERENCES)),
//            scope = CoroutineScope(Dispatchers.IO + SupervisorJob()),
//            produceFile = { appContext.preferencesDataStoreFile(USER_PREFERENCES) }
//        )
//    }
//}